package com.intpro.demo.Controller;

import com.intpro.demo.DAO.CommonRep;
import com.intpro.demo.DAO.User;
import com.intpro.demo.Service.MessageSevice;
import com.intpro.demo.Utils.MyAnnotations.Authorization;
import com.intpro.demo.Utils.MyAnnotations.CurrentUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
@RequestMapping("api/message")
public class MessageController
{

	@Autowired
	private MessageSevice messageSevice;

	@Authorization
	@PostMapping("getMyMsg")
	public CommonRep getMyMsg(@CurrentUser User u)
	{
		CommonRep rep = new CommonRep();
		rep.data = messageSevice.findMsgByToid(u.id);
		return rep;
	}

}
